package cn.wolfcode.crm.web.controller;

import cn.wolfcode.crm.service.IPermissionService;
import cn.wolfcode.crm.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/permission")
public class PermissionController {

    @Autowired
    private IPermissionService permissionService;
    
    @RequestMapping("/permission")
    public String permission(Model model){

        return "system/permission";
    }
    @RequestMapping("/selectAll")
    @ResponseBody
    public Object selectAll(){
        return permissionService.listAll();
    }
    
    @RequestMapping("/selectByRoleId")
    @ResponseBody
    public Object selectByRoleId(Long id){
        return permissionService.selectByRoleId(id);
    }

    @RequestMapping("/reload")
    @ResponseBody
    public Object reload(){
        try {
            permissionService.reload();
        } catch (Exception e) {
            e.printStackTrace();
            return new JsonResult().mark(e.getMessage());
        }
        return new JsonResult();
    }

//    @RequestMapping("/query")
//    @ResponseBody
//    public Object query(QueryObject qo){
//        return permissionService.query(qo);
//    }

}
